package com.wanma;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class JDK18Test01 {
	// 这是常规的Collections的排序的写法，需要对接口方法重写
	public void test1() {
		List<String> list = Arrays.asList("aaa", "fsa", "ser", "eere");
		Collections.sort(list, new Comparator<String>() {
			@Override
			public int compare(String o1, String o2) {
				return o2.compareTo(o1);
			}
		});
		for (String string : list) {
			System.out.println(string);
		}
	}

	// 这是带参数类型的Lambda的写法
	public void testLamda1() {
		List<String> list = Arrays.asList("aaa", "fsa", "ser", "eere");
		Collections.sort(list, (Comparator<? super String>) (String a, String b) -> {
			return b.compareTo(a);
		});
		for (String string : list) {
			System.out.println(string);
		}
	}

	// 这是不带参数的lambda的写法
	public void testLamda2() {
		List<String> list = Arrays.asList("aaa", "fsa", "ser", "eere");
		Collections.sort(list, (a, b) -> b.compareTo(a));
		Collections.sort(list, (Comparator<String>) (String a, String b) -> {
			return 0;
		});
		Collections.sort(list, (a, b) -> b.compareTo(a));
		// Collections.swap(list, i, j);
		for (String string : list) {
			System.out.println(string);
		}
	}
	public static void main(String[] args) {
	//	String o  = String :: valueOf;
	//	Object o = JDK18Test01::test1;
	}
}
